<template>
  <div>
    <el-row>
      <el-col :span="4" :offset="2">观影时间:今天&nbsp;<el-button @click="getTimes(dateInfor.Today)" class="a">{{dateInfor.Today}}</el-button></el-col>
      <el-col :span="3" :offset="1"> <el-button @click="getTimes(dateInfor.Tomorrow)" class="a">  {{dateInfor.Tomorrow}} </el-button>  </el-col>
      <el-col :span="3" :offset="1"><el-button @click="getTimes(dateInfor.atomorrow)" class="a">{{dateInfor.atomorrow}}</el-button></el-col>
    </el-row>
    <div>
      <el-table :data="AllMoviesTimes" class="el_table" align="center">
        <el-table-column type="index" label="今日场次" width="180" align="center"></el-table-column>
        <el-table-column prop="sHour"    label="放映时间"  width="180" align="center" >
          <template slot-scope="scope">
            <i class="el-icon-time"></i>
            {{scope.row.sHour}}
          </template>
        </el-table-column>
        <el-table-column prop="fnLanguage"  label="语言版本"  width="180" align="center"></el-table-column>
        <el-table-column prop="sPlayHall"  label="放映厅" align="center" width="180">              </el-table-column>
        <el-table-column prop="fnPrice"     label="售价(元)" width="180" align="center"></el-table-column>

        <el-table-column label="选座购票"width="180" align="center">
          <template slot-scope="scope">
            <el-button @click="toSeat(scope.row)" type="text" size="small" style="font-size:16px">选座购票</el-button>
          </template>
        </el-table-column>
      </el-table>
    </div>
  </div>
</template>

<script>
    export default {
        name: "SellingTickets",
        data(){
            return{
                //{"id":1,"sId":null,"nfId":null,"ofId":1,"sDay":"12月19日","sHour":"8:00","sBar":1}

                 AllMoviesTimes:[
                     {
                         id:'',  //场次唯一id
                         sDay:'',//日期
                         sHour:'',//场次时间
                         sPlayHall:'' ,//场次的厅室
                         fnLanguage:'中文',
                         fnPrice:40,
                         fnName:'',//电影名
                         fnImg:'',

                     }
                 ],
                dateInfor:{
                    fnId: '',
                    Today: '',
                    Tomorrow: '',
                    atomorrow: ''
                }
                // tableData:[{
                //     date:'12:30',
                //     language:'中文',
                //     showRoom:'3号激光厅',
                //     money:'45',
                //
                // },
                //     // {
                //     //     date:'11:00',
                //     //     language:'中文',
                //     //     showRoom:'4号激光厅',
                //     //     money:'40',
                //     //
                //     // },
                //     // {
                //     //     date:'13:00',
                //     //     language:'中文',
                //     //     showRoom:'7号激光厅',
                //     //     money:'30',
                //     //
                //     // }
                // ]
            }
        },
        methods:{
            isShow(){
                var vm= this;
                this.dateInfor = this.$route.params.dateInfor;
                console.log("123"+this.dateInfor.fTime);
                var id=this.dateInfor.fnId;
                var date = this.dateInfor.Today;
                console.log(this.dateInfor.fnId);
                console.log(date);
               this.axios({
                   url:'http://localhost:80/api/hotmovie/getMoviesTimes',
                   params:{
                       ofId: id,
                       sDay: date
                   }
               }).then(function (res) {
                   if (res.data.success){
                      console.log(res.data.data);
                       vm.AllMoviesTimes = res.data.data;
                   }
               })
            },

            getTimes(sDay){
                var vm= this;
                this.dateInfor = this.$route.params.dateInfor;
                console.log(this.dateInfor);
                var id=this.dateInfor.fnId;
                console.log(this.dateInfor.fnId);
                this.axios({
                    url:'http://localhost:80/api/hotmovie/getMoviesTimes',
                    params:{
                        ofId: id,
                        sDay: sDay
                    }
                }).then(function (res) {
                    if (res.data.success){
                        console.log(res.data.data);
                        vm.AllMoviesTimes = res.data.data;
                    }
                })
            },

            toSeat(a){
                var pdata={
                    fname:a.fnName,//电影名
                    hallId:a.sPlayHall,//影厅
                    sDay:a.sDay+" "+a.sHour,//日期
                    fPrice:a.fnPrice,//价格
                    fImg:a.fnImg,    //海报
                    sid:a.id,
                    fid:this.dateInfor.fnId,
                    fTime:this.$parent.onMovie.fnTime,
                    stateType:2       //2 买票状态
                };
                console.log(pdata)
                this.$router.push({name:'seatSell',params:{'pdata':pdata}})
            }

        },
        created() {
            this.isShow();
        },
        activated() {
            this.$router.push('/movieInfor');
        }
    }
</script>

<style scoped>
  .a{
    border: none;
    color: black;
    margin-left: -5px;
  }
</style>
